From 558b5c7a896045a1378e6d1569a008bb85e8bf44 Mon Sep 17 00:00:00 2001 From: "iap10@freefall.cl.cam.ac.uk" Date: Wed, 7 Sep 2005 23:11:44 +0000 Subject: [PATCH] More tools PAE fixes to avoid loosing high-order pte bits. Signed-off-by: ian@xensource.com --- tools/libxc/xc_linux_build.c | 20 ++++++++++++++------ tools/libxc/xc_private.c | 6 +++--- tools/libxc/xenctrl.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index 498cb75542..4525996f2a 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -57,7 +57,7 @@ static int probeimageformat(char *image, } #define alloc_pt(ltab, vltab) \ - ltab = page_array[ppt_alloc++] << PAGE_SHIFT; \ + ltab = (unsigned long long)(page_array[ppt_alloc++]) << PAGE_SHIFT; \ if (vltab != NULL) { \ munmap(vltab, PAGE_SIZE); \ } \ @@ -128,9 +128,9 @@ static int setup_pg_tables_pae(int xc_handle, u32 dom, l1_pgentry_64_t *vl1tab=NULL, *vl1e=NULL; l2_pgentry_64_t *vl2tab=NULL, *vl2e=NULL; l3_pgentry_64_t *vl3tab=NULL, *vl3e=NULL; - unsigned long l1tab = 0; - unsigned long l2tab = 0; - unsigned long l3tab = 0; + unsigned long long l1tab = 0; + unsigned long long l2tab = 0; + unsigned long long l3tab = 0; unsigned long ppt_alloc; unsigned long count; @@ -139,7 +139,13 @@ static int setup_pg_tables_pae(int xc_handle, u32 dom, alloc_pt(l3tab, vl3tab); vl3e = &vl3tab[l3_table_offset_pae(dsi_v_start)]; ctxt->ctrlreg[3] = l3tab; - + + if(l3tab>0xfffff000) + { + fprintf(stderr,"L3TAB = %llx above 4GB!\n",l3tab); + goto error_out; + } + for ( count = 0; count < ((v_end-dsi_v_start)>>PAGE_SHIFT); count++) { if ( !((unsigned long)vl1e & (PAGE_SIZE-1)) ) @@ -525,12 +531,14 @@ static int setup_guest(int xc_handle, physmap = physmap_e = xc_map_foreign_range( xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[physmap_pfn++]); + for ( count = 0; count < nr_pages; count++ ) { if ( xc_add_mmu_update(xc_handle, mmu, - (page_array[count] << PAGE_SHIFT) | + ((unsigned long long)page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, count) ) { + fprintf(stderr,"m2p update failure p=%lx m=%lx\n",count,page_array[count] ); munmap(physmap, PAGE_SIZE); goto error_out; } diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 4cbfa2f1f2..58392cc07e 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -116,7 +116,7 @@ int xc_mmuext_op( if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 ) { - fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to" + fprintf(stderr, "Dom_mmuext operation failed (rc=%ld errno=%d)-- need to" " rebuild the user-space tool set?\n",ret,errno); } @@ -172,7 +172,7 @@ xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom) } int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, - unsigned long ptr, unsigned long val) + unsigned long long ptr, unsigned long long val) { mmu->updates[mmu->idx].ptr = ptr; mmu->updates[mmu->idx].val = val; @@ -229,7 +229,7 @@ int xc_memory_op(int xc_handle, if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 ) { - fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to" + fprintf(stderr, "hypercall failed (rc=%ld errno=%d)-- need to" " rebuild the user-space tool set?\n",ret,errno); } diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 16a6339a5e..0c89052111 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -521,7 +521,7 @@ struct xc_mmu { typedef struct xc_mmu xc_mmu_t; xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom); int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, - unsigned long ptr, unsigned long val); + unsigned long long ptr, unsigned long long val); int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu); #endif -- 2.30.2